/**
 * Licensee: Carla Painemilla
 * License Type: Evaluation
 */
package ormsamples;

import org.orm.*;
public class DeleteDiagnosticoData {
	public void deleteTestData() throws PersistentException {
		PersistentTransaction t = orm.DiagnosticoPersistentManager.instance().getSession().beginTransaction();
		try {
			orm.DAOFactory lDAOFactory = orm.DAOFactory.getDAOFactory();
			orm.dao.CursoDAO oRMCursoDAO = lDAOFactory.getCursoDAO();
			orm.Curso oRMCurso = oRMCursoDAO.loadCursoByQuery(null, null);
			// Delete the persistent object
			oRMCursoDAO.delete(oRMCurso);
			orm.dao.AlumnoDAO oRMAlumnoDAO = lDAOFactory.getAlumnoDAO();
			orm.Alumno oRMAlumno = oRMAlumnoDAO.loadAlumnoByQuery(null, null);
			// Delete the persistent object
			oRMAlumnoDAO.delete(oRMAlumno);
			orm.dao.AnotacionDAO oRMAnotacionDAO = lDAOFactory.getAnotacionDAO();
			orm.Anotacion oRMAnotacion = oRMAnotacionDAO.loadAnotacionByQuery(null, null);
			// Delete the persistent object
			oRMAnotacionDAO.delete(oRMAnotacion);
			orm.dao.AnotadorDAO oRMAnotadorDAO = lDAOFactory.getAnotadorDAO();
			orm.Anotador oRMAnotador = oRMAnotadorDAO.loadAnotadorByQuery(null, null);
			// Delete the persistent object
			oRMAnotadorDAO.delete(oRMAnotador);
			orm.dao.TipoDAO oRMTipoDAO = lDAOFactory.getTipoDAO();
			orm.Tipo oRMTipo = oRMTipoDAO.loadTipoByQuery(null, null);
			// Delete the persistent object
			oRMTipoDAO.delete(oRMTipo);
			orm.dao.SubsectorDAO oRMSubsectorDAO = lDAOFactory.getSubsectorDAO();
			orm.Subsector oRMSubsector = oRMSubsectorDAO.loadSubsectorByQuery(null, null);
			// Delete the persistent object
			oRMSubsectorDAO.delete(oRMSubsector);
			t.commit();
		}
		catch (Exception e) {
			t.rollback();
		}
		
	}
	
	public static void main(String[] args) {
		try {
			DeleteDiagnosticoData deleteDiagnosticoData = new DeleteDiagnosticoData();
			try {
				deleteDiagnosticoData.deleteTestData();
			}
			finally {
				orm.DiagnosticoPersistentManager.instance().disposePersistentManager();
			}
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}
}
